home *** CD-ROM | disk | FTP | other *** search
/ PCMania 64 / PCMania CD64_1.iso / phy / phy003 / 3d / skynet.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-04-08  |  5.5 KB  |  168 lines

  1.                                         {
  2. Vulkanus program....
  3. By Skynet              'My Computer, My God, My Friend, My mind...'             }
  4.  
  5.  
  6. PROGRAM ALYSYUM;
  7.  
  8. Uses Crt, Grflib, Grafiks;
  9.  
  10. Const DISTANCIA=1;
  11.       Tecta=0.017453292519943295769;
  12.       COST =0.999847695156391239157;
  13.       SINT =0.017452406437283512819;
  14.  
  15. Type TresD=  Record
  16.              X,Y,Z:extended;
  17.              End;
  18.      Estel =Array[1..14] of TresD;
  19.  
  20. Var dades:Estel;
  21.     I,OrigeX,OrigeY,sentitX,sentitY:Integer;
  22.     PV,PV2:Byte;
  23.     c:Extended;
  24.  
  25. Procedure Valors(Var d:Estel);
  26.  
  27.    Begin
  28.          d [1].x:=   0;     d [1].y:=  80;     d [1].z:=   0;
  29.          d [2].x:=  80;     d [2].y:=   0;     d [2].z:=   0;
  30.          d [3].x:=   0;     d [3].y:= -80;     d [3].z:=   0;
  31.          d [4].x:= -80;     d [4].y:=   0;     d [4].z:=   0;
  32.          d [5].x:= -20;     d [5].y:=  20;     d [5].z:=  -20;
  33.          d [6].x:= -20;     d [6].y:=  20;     d [6].z:=   20;
  34.          d [7].x:=  20;     d [7].y:=  20;     d [7].z:=   20;
  35.          d [8].x:=  20;     d [8].y:=  20;     d [8].z:=  -20;
  36.          d [9].x:= -20;     d [9].y:= -20;     d [9].z:=  -20;
  37.          d[10].x:=  20;     d[10].y:= -20;     d[10].z:=  -20;
  38.          d[11].x:=  20;     d[11].y:= -20;     d[11].z:=   20;
  39.          d[12].x:= -20;     d[12].y:= -20;     d[12].z:=   20;
  40.          d[13].x:=   0;     d[13].y:=   0;     d[13].z:=   80;
  41.      d[14].x:=   0;     d[14].y:=   0;     d[14].z:=  -80;
  42.    End;
  43.  
  44. Procedure lines(x1, y1, x2, y2: extended;c,pv:byte;origeX,OrigeY:integer);
  45.    Begin
  46.     fLinea(round(x1) + origeX,round(y1) + origeY,round(x2) + origeX,round(y2) + origeY,c,PV);
  47.    End;
  48.  
  49. Procedure Dibuixar(d:Estel;c:integer;pv:byte;OX,OY:Integer);
  50.  
  51.    Begin
  52.       Lines(d [1].x,d [1].y,d [5].x,d [5].y,c,pv,ox,oy);
  53.       Lines(d [1].x,d [1].y,d [6].x,d [6].y,c,pv,ox,oy);
  54.       Lines(d [1].x,d [1].y,d [7].x,d [7].y,c,pv,ox,oy);
  55.       Lines(d [1].x,d [1].y,d [8].x,d [8].y,c,pv,ox,oy);
  56.       Lines(d [4].x,d [4].y,d [5].x,d [5].y,c,pv,ox,oy);
  57.       Lines(d [4].x,d [4].y,d [6].x,d [6].y,c,pv,ox,oy);
  58.       Lines(d [4].x,d [4].y,d [9].x,d [9].y,c,pv,ox,oy);
  59.       Lines(d [4].x,d [4].y,d[12].x,d[12].y,c,pv,ox,oy);
  60.       Lines(d [2].x,d [2].y,d [7].x,d [7].y,c,pv,ox,oy);
  61.       Lines(d [2].x,d [2].y,d [8].x,d [8].y,c,pv,ox,oy);
  62.       Lines(d [2].x,d [2].y,d[11].x,d[11].y,c,pv,ox,oy);
  63.       Lines(d [2].x,d [2].y,d[10].x,d[10].y,c,pv,ox,oy);
  64.       Lines(d [3].x,d [3].y,d [9].x,d [9].y,c,pv,ox,oy);
  65.       Lines(d [3].x,d [3].y,d[10].x,d[10].y,c,pv,ox,oy);
  66.       Lines(d [3].x,d [3].y,d[12].x,d[12].y,c,pv,ox,oy);
  67.       Lines(d [3].x,d [3].y,d[11].x,d[11].y,c,pv,ox,oy);
  68.       Lines(d[13].x,d[13].y,d [6].x,d [6].y,c,pv,ox,oy);
  69.       Lines(d[13].x,d[13].y,d [7].x,d [7].y,c,pv,ox,oy);
  70.       Lines(d[13].x,d[13].y,d[12].x,d[12].y,c,pv,ox,oy);
  71.       Lines(d[13].x,d[13].y,d[11].x,d[11].y,c,pv,ox,oy);
  72.       Lines(d[14].x,d[14].y,d [5].x,d [5].y,c,pv,ox,oy);
  73.       Lines(d[14].x,d[14].y,d [8].x,d [8].y,c,pv,ox,oy);
  74.       Lines(d[14].x,d[14].y,d [9].x,d [9].y,c,pv,ox,oy);
  75.       Lines(d[14].x,d[14].y,d[10].x,d[10].y,c,pv,ox,oy);
  76.       Lines(d [6].x,d [6].y,d [5].x,d [5].y,c,pv,ox,oy);
  77.       Lines(d [6].x,d [6].y,d [7].x,d [7].y,c,pv,ox,oy);
  78.       Lines(d [6].x,d [6].y,d[12].x,d[12].y,c,pv,ox,oy);
  79.       Lines(d[10].x,d[10].y,d [9].x,d [9].y,c,pv,ox,oy);
  80.       Lines(d[10].x,d[10].y,d [8].x,d [8].y,c,pv,ox,oy);
  81.       Lines(d[10].x,d[10].y,d[11].x,d[11].y,c,pv,ox,oy);
  82.       Lines(d [8].x,d [8].y,d [5].x,d [5].y,c,pv,ox,oy);
  83.       Lines(d [8].x,d [8].y,d [7].x,d [7].y,c,pv,ox,oy);
  84.       Lines(d[11].x,d[11].y,d [7].x,d [7].y,c,pv,ox,oy);
  85.       Lines(d[11].x,d[11].y,d[12].x,d[12].y,c,pv,ox,oy);
  86.       Lines(d[12].x,d[12].y,d [9].x,d [9].y,c,pv,ox,oy);
  87.       Lines(d [9].x,d [9].y,d [5].x,d [5].y,c,pv,ox,oy);
  88.    End;
  89.  
  90. Procedure Rotx(var Dades:Estel);
  91.    Var i : integer;
  92.    Begin
  93.      for i := 1 to 14 do
  94.        begin
  95.          dades[i].x := dades[i].x;
  96.          dades[i].y :=dades[i].y * cost + dades[i].z * sint;
  97.          dades[i].z :=-dades[i].y * sint + dades[i].z * cost;
  98.        end;
  99.    End;
  100.  
  101. Procedure Roty(var dades:Estel);
  102.    Var i : integer;
  103.    Begin
  104.      For i := 1 to 14 do
  105.        Begin
  106.          dades[i].x := dades[i].x * cost - dades[i].z * sint;
  107.          dades[i].y := dades[i].y;
  108.          dades[i].z := dades[i].x * sint + dades[i].z * cost;
  109.        End;
  110.    End;
  111.  
  112. Procedure Rotz(var dades:estel);
  113.    Var i : integer;
  114.    Begin
  115.       For i := 1 to 14 do
  116.         Begin
  117.            dades[i].x := dades[i].x * cost + dades[i].y * sint;
  118.            dades[i].y := -dades[i].x * sint + dades[i].y * cost;
  119.            dades[i].z := dades[i].z;
  120.         End;
  121.    End;
  122.  
  123.  
  124. {----------------------------------------------------------------------------}
  125.  
  126. BEGIN
  127.  
  128.  
  129.   Sentitx:=1;
  130.   Sentity:=1;
  131.   OrigeX:=160;
  132.   OrigeY:=100;
  133.   Valors(dades);
  134.   ModoGrafico;
  135.   PV:=CreaVirtual;     {Destapar per a PV}
  136.   PV2:=CreaVirtual;
  137.   c:=16;
  138.   For I:=0 to 199 do
  139.     Begin
  140.      linea(0,i,319,i,round(c),pv2);
  141.      c:=c+0.075;
  142.     End;
  143.   fBorraPantalla(0,0);
  144.   repeat
  145.     WaitVR;
  146.     CopiaPantalla(PV2,PV);
  147.     Dibuixar( dades,1,pv,OrigeX,OrigeY);
  148.     If ((OrigeX=80) or (OrigeX=240)) then
  149.        sentitx:=sentitX*(-1);
  150.     If ((Origey=80) or (Origey=120)) then
  151.        sentity:=Sentity*(-1);
  152.     origex:=origex+(sentitx);
  153.     origey:=origey+(sentity);
  154.     rotz(dades);
  155.     rotx(dades);
  156.     roty(dades);
  157.     CopiaPantalla(PV,0);
  158.     fBorraPantalla(0,PV);
  159.   Until keypressed;
  160.   FadeDown(10000,1,0);      {Encara que no ve al cas.... :-)  }
  161.   {CopiaPantalla(PV,0);}
  162.  
  163.   Readln;
  164.   {DestVirtual(PV);}
  165.   ModoTexto;
  166.  
  167. END.
  168.